//
// Created by User on 24-10-3.
//

#ifndef STREAM_H
#define STREAM_H

#include "demuxer_interface.hpp"
#include "packet_provider.hpp"


extern "C" {
struct AVStream;
}

namespace demuxer
{
    class general_stream final
    {
    public:
        general_stream(demuxer_interface& demuxer, AVStream* stream);

        ~general_stream() = default;

        AVCodecParameters* get_parameters() const;

        AVRational get_timebase() const;

        utils::media_packet get_packet();

        AVStream* get_stream() const;

        int total_frame() const;

    private:
        demuxer_interface& m_demuxer;
        AVStream* m_stream;
    };

    class video_stream
        : public interfaces::video_packet_provider
    {
    public:
        video_stream(demuxer_interface& demuxer, AVStream* stream);

        ~video_stream() override = default;

        utils::media_packet get_packet() override;

        const AVCodecParameters* get_codec() const override;

        AVRational get_timebase() const override;

        AVStream* get_stream() const;

        int total_frames() const override;

    private:
        general_stream m_stream;
    };

    class audio_stream
        : public interfaces::audio_packet_provider
    {
    public:
        audio_stream(demuxer_interface& demuxer, AVStream* stream);

        ~audio_stream() override = default;

        utils::media_packet get_packet() override;

        const AVCodecParameters* get_codec() const override;

        AVRational get_timebase() const override;

        AVStream* get_stream() const;

        int total_frames() const override;

    private:
        general_stream m_stream;
    };
} // demuxer

#endif //STREAM_H
